import React, { Component } from 'react'

export default class List extends Component {
    constructor(){
        super();
        this.state={
            num:1
        }
    }
    setnum = ()=>{
        let num = Math.round(Math.random()*100)
        this.setState({
           num:num
        })
    }
  render() {
    let result = ''
    if(this.state.num<60){
        result = '不及格'
    }else if(this.state.num<70){
        result = '及格'
    }else if(this.state.num<80){
        result = '良好'
    }else{
        result = '优秀'
    }
    return (
      <React.Fragment>
        <div>
        分数:{this.state.num}--{result}<button onClick={this.setnum}>点击修改num的值</button>
        </div>
      </React.Fragment>
    )
  }
}
